#! /usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Teny

from django import forms

class BootStrapModelForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            # 如上需要保留原来的属性
            if field.widget.attrs:
                field.widget.attrs['class'] = 'form-control'
                field.widget.attrs['placeholder'] = field.label
            else:
                field.widget.attrs = {'class': 'form-control', 'placeholder': field.label}

            # # 'autocomplate':'off' 去掉历史显示
            # if name == 'create_time':
            #     field.widget.attrs = {'class': 'form-control', 'placeholder': field.label, 'autocomplate': 'off'}
            # else:
            #     field.widget.attrs = {'class': 'form-control', 'placeholder': field.label}